package org.hs.phd.odi.tracking.performanceevaluation;

import java.awt.Polygon;
import java.awt.Rectangle;

import org.hs.phd.common.geometry.DistanceNormKit;
import org.hs.phd.common.geometry.Norm2D;
import org.hs.phd.common.simpleplayer.ImageSequenceFrame;

public class CentersDistancePixelsMetric  extends AbstractTrackingPerformanceMetric  {

	private Norm2D euclidianNorm2D;
	
	public CentersDistancePixelsMetric(){
		euclidianNorm2D = DistanceNormKit.getEuclNorm2D();
	}

	@Override
	protected float compute(ImageSequenceFrame frame, Polygon groundTruthTrackShape, Polygon computedTrackShape) {
		Rectangle gtBoundingBox = groundTruthTrackShape.getBounds();
		Rectangle compBoundingBox = computedTrackShape.getBounds();
		
		return (float) euclidianNorm2D.distance(gtBoundingBox.getCenterX(), gtBoundingBox.getCenterY(), compBoundingBox.getCenterX(), compBoundingBox.getCenterY());
	}

	@Override
	public String getShortName() {
		return "Cent.Dist.Px";
	}

	@Override
	public String getName() {
		return "Centers Distance";
	}

	@Override
	public String getUnitName() {
		return "Pixels";
	}

	@Override
	public float getRangeMin() {
		return 0;
	}

	@Override
	public float getRangeMax() {
		return 100;
	}
}
